$(document).ready(function () {
    initJbxx();
    initTree();
});


/**
 * 加载用户基本信息
 */
function initJbxx() {
    var ryxm = getParam("ryxm");
    var dldm = getParam("dldm");
    var rygh = getParam("rygh");
    $('#ryxm').text(ryxm);
    $('#dldm').text(dldm);
    if("null" == rygh){
        $('#rygh').text('空');
    }else{
        $('#rygh').text(rygh);
    }
}

/**
 * 获取参数
 */
function getParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)
        return decodeURI(r[2]);   //对参数进行decodeURI解码
    return null;
}


/**
 * 加载树
 */
function initTree() {
    var zclsh = Common.GetRequest().zclsh;   //注册流水号
    $.ajax({
        type: "GET",
        dataType: "json",
        url: "user/getQxList/" + zclsh,
        success: function (jsonData) {
            if (jsonData.code == 200) {   //查询成功
                var setting = {
                    view: {
                        fontCss: {"font-family": "Microsoft YaHei"},
                        selectedMulti: false,
                        showIcon: false
                    },
                    data: {
                        simpleData: {
                            enable: true
                        }
                    }
                };
                $.fn.zTree.init($("#qxList"), setting, jsonData.menuTreeList);
                $("[id*='tree']").css("font-size", "13px");
                var treeObj = $.fn.zTree.getZTreeObj("qxList");
                var nodes = treeObj.getNodes();
                if (nodes.length > 0) {
                    //默认展开一级节点
                    treeObj.expandNode(nodes[0], true, false, true);
                }
            }else {
                LayerWn.showFailAlert(jsonData.msg);
            }
        }
    });
}
